<?php
$filePath=str_replace('\\','/',__FILE__);
$filePath=str_replace('public/commons/commons.php', '', $filePath);
require_once $filePath.'config/config.php';

function showHtml($htmlFile,$smt,$templateFile) {
	$contents=$smt->fetch($templateFile);
	if (file_exists($htmlFile)) {
		unlink($htmlFile);
	}
	$fp=fopen($htmlFile, 'wb');
	fwrite($fp, $contents);
	fclose($fp);

	redirect2html($htmlFile,$smt);
}
function redirect2html($htmlFile,$smt){
	if (file_exists($htmlFile)) {
		msg($smt,'自动跳转静态页面','正在准备数据...',$htmlFile,'public/msg.html','5');
	}
}
function msg($smt,$title, $msg, $url, $templateFile, $time = "0")
{
    $sname = $title;
    $smt->assign('msg_title',$title);
    $mmsg = !empty($msg) ? $msg : "默认消息";	//默认显示“默认消息”
    $smt->assign('msg', $mmsg);
    $ttime = ($time != 0) ? $time : 0;			//跳转时间，默认为“3”
    $smt->assign('time_refresh', $ttime);
    $smt->assign('url', $url);					//显示的URL地址
    $smt->assign('location', $url);			//跳转到的地址*
    $mesg = $smt->fetch($templateFile);		//网页模板
    echo $mesg;
}
function P($msg){
	Debug::addmsg($msg,0);
}
function PSQL($msg){
	Debug::addmsg($msg,2);
}
function PA($msg){
	DEBUG::addmsg($msg,1);
}
